<?php
class pdd{
    //私有1
    private static $names;
    private static $root;
    private static $pass;
    private static $pdo;

    public function inner_pdo($name,$root,$pass){
        //私有的
        self::$names = $name;
        self::$root = $root;
        self::$pass = $pass;

        $pdo = new PDO('mysql:host=127.0.0.1;dbname='.self::$names,self::$root,self::$pass);
        self::$pdo=$pdo;

    }

    //查询
    public static function select($table)
    {
        $data = self::$pdo->query("select * from ".$table)->fetchAll(PDO::FETCH_ASSOC);
        return $data;
    }

    //查询一条
    public static function find($table,$id){
        $data = self::$pdo->query("select * from ".$table." where r_id=".$id)->fetch(PDO::FETCH_ASSOC);
        return $data;
    }

    //添加
    public static function create($table,$arr){
        $data = self::$pdo->prepare("insert into ".$table."value ($arr)")->query();
        return $data;
    }



}
?>